<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="AlmacenListForm">

        <p:panel header="#{seriesBundle.ListAlmacenTitle}">
            <p:contextMenu id="AlmacenDataTableContextMenu" for="datalist">  
                <p:menuitem value="#{seriesBundle.Create}" onclick="document.getElementById('AlmacenListForm:createButton').click();" icon="ui-icon-plus"/>
                <p:menuitem value="#{seriesBundle.View}" onclick="document.getElementById('AlmacenListForm:viewButton').click();" icon="ui-icon-search"/>
                <p:menuitem value="#{seriesBundle.Edit}" onclick="document.getElementById('AlmacenListForm:editButton').click();" icon="ui-icon-pencil"/>
                <p:menuitem value="#{seriesBundle.Delete}" onclick="document.getElementById('AlmacenListForm:deleteButton').click();" icon="ui-icon-trash"/>
                <p:separator/>
                <p:menuitem value="#{seriesBundle.AlmacenMenuItem_obtenidoCollection}" icon="ui-icon-search"  action="#{almacenController.navigateObtenidoCollection}" disabled="#{empty almacenController.selected.obtenidoCollection}" ajax="false"/>  
            </p:contextMenu>
            <p:dataTable id="datalist"
                         value="#{almacenController.items}"
                         var="item"
                         rowKey="#{item.idAlmacen}"
                         paginator="true"
                         rows="10"
                         rowsPerPageTemplate="5,10,20,30,40,50"
                         selectionMode="single"
                         selection="#{almacenController.selected}">

                <p:ajax event="rowSelect"   update=":AlmacenListForm:createButton :AlmacenListForm:viewButton :AlmacenListForm:editButton :AlmacenListForm:deleteButton :AlmacenListForm:AlmacenDataTableContextMenu" listener="#{almacenController.resetParents}"/>
                <p:ajax event="rowUnselect" update=":AlmacenListForm:createButton :AlmacenListForm:viewButton :AlmacenListForm:editButton :AlmacenListForm:deleteButton :AlmacenListForm:AlmacenDataTableContextMenu" listener="#{almacenController.resetParents}"/>
                <p:ajax event="rowDblselect" onsuccess="document.getElementById('AlmacenListForm:viewButton').click();"/>

                <p:column sortBy="#{item.idAlmacen}" filterBy="#{item.idAlmacen}">
                    <f:facet name="header">
                        <h:outputText value="#{seriesBundle.ListAlmacenTitle_idAlmacen}"/>
                    </f:facet>
                    <h:outputText value="#{item.idAlmacen}"/>
                </p:column>


                <p:column sortBy="#{item.descripcion}" filterBy="#{item.descripcion}">
                    <f:facet name="header">
                        <h:outputText value="#{seriesBundle.ListAlmacenTitle_descripcion}"/>
                    </f:facet>
                    <h:outputText value="#{item.descripcion}"/>
                </p:column>


                <p:column sortBy="#{item.proposito}" filterBy="#{item.proposito}">
                    <f:facet name="header">
                        <h:outputText value="#{seriesBundle.ListAlmacenTitle_proposito}"/>
                    </f:facet>
                    <h:outputText value="#{item.proposito}"/>
                </p:column>


                <p:column sortBy="#{item.comentarios}" filterBy="#{item.comentarios}">
                    <f:facet name="header">
                        <h:outputText value="#{seriesBundle.ListAlmacenTitle_comentarios}"/>
                    </f:facet>
                    <h:outputText value="#{item.comentarios}"/>
                </p:column>


                <p:column sortBy="#{item.capacidad}" filterBy="#{item.capacidad}">
                    <f:facet name="header">
                        <h:outputText value="#{seriesBundle.ListAlmacenTitle_capacidad}"/>
                    </f:facet>
                    <h:outputText value="#{item.capacidad}"/>
                </p:column>


                <p:column sortBy="#{item.espacioLibre}" filterBy="#{item.espacioLibre}">
                    <f:facet name="header">
                        <h:outputText value="#{seriesBundle.ListAlmacenTitle_espacioLibre}"/>
                    </f:facet>
                    <h:outputText value="#{item.espacioLibre}"/>
                </p:column>


            </p:dataTable>

            <p:commandButton id="createButton"                             icon="ui-icon-plus"   value="#{seriesBundle.Create}" actionListener="#{almacenController.prepareCreate}" update=":AlmacenCreateForm" oncomplete="AlmacenCreateDialog.show()"/>
            <p:commandButton id="viewButton"   style="visibility: hidden;" icon="ui-icon-search" value="#{seriesBundle.View}" update=":AlmacenViewForm" oncomplete="AlmacenViewDialog.show()" disabled="#{empty almacenController.selected}"/>
            <p:commandButton id="editButton"   style="visibility: hidden;" icon="ui-icon-pencil" value="#{seriesBundle.Edit}" update=":AlmacenEditForm" oncomplete="AlmacenEditDialog.show()" disabled="#{empty almacenController.selected}"/>
            <p:commandButton id="deleteButton" style="visibility: hidden;" icon="ui-icon-trash"  value="#{seriesBundle.Delete}" actionListener="#{almacenController.delete}" update=":growl,datalist" disabled="#{empty almacenController.selected}"/>

        </p:panel>
    </h:form>

</ui:composition>